<template>
  <div>
        <nav-bar >
            <div slot="left" @click="backclick"> 
                <img src="@/assets/img/common/back.svg" alt="" class="imgback">
            </div>
            <div slot="center" class="title">
               <div v-for="(item,index) in titles" 
               :key="index" class="title-item"
               :class="{active:index==currentindex}"
               @click="changindex(index)">{{item}}</div>
            </div>
        </nav-bar>
  </div>
</template>

<script>
import NavBar from '@/components/common/navbar/NavBar'
export default {
components:{
        NavBar
    },
    data() {
        return {
            titles:['商品','参数','评论','推荐'],
            currentindex: 0
        }
    },
    methods: {
        changindex(index){
            this.currentindex = index
            this.$emit("titleClick",index)
        },
        backclick(){
            this.$router.go(-1)
        }
    },
}
</script>

<style scoped>
.title{
    display: flex;
}
.title-item{
    flex: 1;
    font-size: 14px;
}
.active{
    color: pink;
    border-bottom: 1px solid pink;
}
.imgback{
    vertical-align: middle;
}
</style>